/*
 * Copyright (c) 2007-2020 西安交通信息投资营运有限公司 版权所有
 * 作者:马星俊
 */

import React, {ReactText} from 'react';
import {Tree} from 'antd';

export interface ParamProps {
  onChange: (keys: any, info: any) => void;
  tree: [];
  value: ReactText[];
}

const FunctionTree: React.FC<ParamProps> = (props) => {
  const {onChange, tree, value} = props;
  const onclick = (checkedKeys: any, info: any) => {
    onChange(checkedKeys, info.halfCheckedKeys)
  }
  return (
    <div>
      {tree && tree.length ? (
        <Tree style={{maxHeight: '300px', padding: "10px 5px", overflowY: 'auto'}}
              checkable
              treeData={tree}
              defaultCheckedKeys={value}
              onCheck={onclick}
        />
      ) : null}
    </div>
  );
};

export default FunctionTree;
